<template>
  <div class="writing titleGeneration">
    <loginWindow style="z-index: 99999" v-if="showLogin" @close="showLogin=false"></loginWindow>
    <Nav></Nav>
    <div class="writing_right">
      <div v-show="showTable">
        <div class="titleGenerationTitleList">
          <div class="TitleList_padding">
            <div class="TitleList_top">
              <div class="TitleList_top_left">
                <div class="TitleList_top_title"><span></span>标题列表</div>
                <div class="TitleList_top_txt">
                  <div class="top_txt_dd">
                    <div class="txt_dd_l">共计生成 {{ allCount }} 条文章标题<span>已选择 {{ selectedCount }} /
												{{ allCount }}</span></div>
                    <div class="txt_dd_r">标题重复检测：在标题入库的时候会自动对标题去重，如果标题在我的文章里已经存在则不会入库。</div>
                  </div>
                </div>
              </div>
            </div>
          </div>

          <div class="TitleList_bottom">
            <div class="TitleList_bottom_title">
              <div class="bottom_title_list">
                <label>
                  <input type="checkbox" v-model="selectAll">
                  序号
                </label>
              </div>
              <div class="bottom_title_list">标题</div>
            </div>
            <div class="TitleList_bottom_content">
              <el-skeleton style="position: absolute; top: 0; left: 0; width: 100%;" :loading="loading"
                           animated :count="generated_quantity">
                <template slot="template">
                  <div class="skeleton_list"
                       style="padding: 0px 30px; border-bottom: 1px solid #f2f6fe;background: #fff; height: 58px; display: flex; align-items: center; justify-content: space-between;">
                    <el-skeleton-item variant="text" style=" width: 85px; height: 20px;"/>
                    <el-skeleton-item variant="text"
                                      style=" width: calc(100% - 115px); height: 20px;"/>
                  </div>
                </template>
              </el-skeleton>
              <div class="bottom_content_list" style=" position: relative; background: #fff; z-index: 3;"
                   :class="{ on: info.checked }" v-for="(info, index) in tableList" :key="index">
                <div class="content_list_li">
                  <label>
                    <input type="checkbox" v-model="info.checked">
                    {{ index + 1 }}
                  </label>
                </div>
                <div class="content_list_li" :class="{ active: info.isActive }">
                  <div class="list_li_txt" @click="titleActive(index)">{{ info.title }}</div>
                  <input type="text" class="list_li_input" :placeholder="info.title"
                         v-model="info.title" ref="inputField" @blur="toggleClass(index)"/>
                </div>
                <div class="content_list_operate" :class="{ active: info.isActive }">
                  <div class="list_operate_li" v-if="info.isActive" @mousedown="handleItemClick"><img
                      src="@a/img/sv5.svg"/>保存
                  </div>
                  <div class="list_operate_li" v-if="!info.isActive" @click="toggleActive(index)"><img
                      src="@a/img/sv5.svg"/>编辑
                  </div>
                  <div class="list_operate_li" @click="deleteInfo(index)"><img
                      src="@a/img/sv6.svg"/>删除
                  </div>
                </div>
              </div>
              <div class="bottom_content_btn">
                <span @click="importTitle = !importTitle">我想导入更多标题 +</span>
              </div>
            </div>

            <div class="TitleList_bottom_btn">
              <div class="top_txt_dt">


                <div class="txt_dt_list">
                  <div class="dt_list_left">违禁词
                    <el-tooltip class="item" effect="dark" content="当AI创作的文章出现违禁词时会自动替换" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
                  <el-select v-model="forbiddenwords_id" placeholder="违禁词替换">
                    <el-option v-for="item in forbiddenwords_inc" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </div>
                <div class="txt_dt_list">
                  <div class="dt_list_left">语言
                    <el-tooltip class="item" effect="dark"
                                content="按哪种语言生成文章" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
                  <el-select v-model="generated_lang" placeholder="默认分类">
                    <el-option v-for="item in lang" :label="item" :value="item">
                    </el-option>
                  </el-select>
                </div>
                <div class="txt_dt_list">
                  <div class="dt_list_left">分类
                    <el-tooltip class="item" effect="dark"
                                content="文章放在哪个分类下" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
                  <el-select v-model="class_type" placeholder="默认分类">
                    <el-option v-for="item in class_types" :key="item.id" :label="item.name"
                               :value="item.id">
                    </el-option>
                  </el-select>
                  <div class="dt_list_icon" @click="showClass"><img src="@a/img/sv4.svg"/></div>
                </div>
                <div class="txt_dt_list">
                  <div class="dt_list_left">审核
                    <el-tooltip class="item" effect="dark" content="自动审核的文章为已审核状态,可以直接发布,手动审核的文章需要人工审核后才可以发布" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
                  <el-select v-model="check_type" placeholder="默认分类">
                    <el-option v-for="item in check_types" :key="item.value" :label="item.label"
                               :value="item.value">
                    </el-option>
                  </el-select>
                </div>
				
                <div class="txt_dt_list">
                  <div class="dt_list_left">字数
                    <el-tooltip class="item" effect="dark" content="生成文字内容字数限制" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
				  <el-select v-model="length" placeholder="字数">
					<el-option v-for="item in length_inc" :label="item" :value="item">
					</el-option>
				  </el-select>				  

                </div>				
				
                <div class="txt_dt_list">
                  <div class="dt_list_left">提示词
                    <el-tooltip class="item" effect="dark" content="" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
				  <el-select v-model="gpt_id" placeholder="">
                    <el-option v-for="item in gpt_inc" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
				  </el-select>					  
                </div>
				
                <div class="txt_dt_list">
                  <div class="dt_list_left">配图
                    <el-tooltip class="item" effect="dark" content="" placement="top-start">
                      <el-button><img src="@a/img/sv12.svg"/></el-button>
                    </el-tooltip>
                  </div>
				  <el-select v-model="img_class_id" placeholder="">
                    <el-option v-for="item in img_inc" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
				  </el-select>				  
                </div>
				
				
				<!--已经有站点了，直接创作就可以了，后续用户一般会知道怎么发-->
                <div class="txt_dt_list txt_dt_btn" @click="doCreateArticle">创建</div>

				
              </div>
            </div>
          </div>
        </div>
        <div class="CategorySettings" v-show="show">
          <div class="CategorySettings_content">
            <div class="CategorySettings_content_title">
              <div class="content_title_dd"><span></span>分类设置</div>
              <div class="content_title_dt" @click="show = !show"><i class="el-icon-close"></i></div>
            </div>
            <div class="CategorySettings_content_txt">
              <div class="content_txt_title">
                <div class="txt_title_list">序号</div>
                <div class="txt_title_list">排序</div>
                <div class="txt_title_list">名称</div>
              </div>
              <div class="content_txt_table">
                <div class="txt_table_scro">
                  <div class="txt_table_list" v-for="(tab, index) in class_types" :key="index">
                    <div class="table_list_li">{{ index + 1 }}</div>
                    <div class="table_list_li ToSort" :class="{ active: tab.isActive }">
                      {{ tab.sort }}
                      <input type="text" v-model="tab.sort"/>
                    </div>
                    <div class="table_list_li Name" :class="{ active: tab.isActive }">
                      <div class="list_li_name">{{ tab.name }}</div>
                      <input type="text" v-model="tab.name"/>
                    </div>
                    <div class="table_list_operate" :class="{ active: tab.isActive }">
                      <div class="list_operate_li" @click="toggleActive2(index)">
                        <img src="@a/img/sv5.svg"/>
                        <span v-if="!tab.isActive">编辑</span>
                        <span v-if="tab.isActive">保存</span>
                      </div>
                      <div class="list_operate_li" @click="deleteInfo2(index)"><img
                          src="@a/img/sv6.svg"/>删除
                      </div>
                    </div>
                  </div>
                </div>
                <div class="txt_table_add">
                  <div class="table_add_btn" @click="addItem">增加信息+</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>


      <!-- 我想要导入更多标题 -->
      <div class="importTitleWindow" v-show="importTitle">
        <div class="Preview_content">
          <div class="Preview_content_title">
            <div class="content_title_left">
              <div class="title_left_dd"><span></span>
                <div v-show="showUpload">导入更多标题</div>
                <div v-show="!showUpload">上传中</div>
              </div>
              <div class="title_left_dt">
                <p>您可以将excel整列复制进来，也可以将记事本里的内容全选复制进来</p>
                <p>标题长度不得超过50个字符</p>
              </div>
            </div>
            <div class="content_title_right" @click="importTitle = !importTitle"><i
                class="el-icon-close"></i></div>
          </div>
          <div class="importTitleWindow_content">
            <div class="importTitleWindow_content_textarea">
              <el-input type="textarea" autosize placeholder="一行一个，回车换行" v-model="user_titles">
              </el-input>
            </div>
            <div class="importTitleWindow_content_bottom">
              <div class="content_bottom_left">保存的时候会自动出除前后空白字符</div>
              <div class="content_bottom_btn">
                <div class="bottom_btn_list" @click="importTitle = !importTitle">取消</div>
                <div class="bottom_btn_list on" @click="addUserTitles">添加</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="Video" v-show="VideoShow">
        <div class="VideoContent">
          <span class="notBlue" @click="handleCancel"><img src="@a/img/closeon.svg"/></span>
          <a-modal
          title="预览视频"
          :width="600"
          :visible="viewVideo"
          :footer="null"
          @cancel="handleCancel"
      >
            <video
                :src="this.videoUrl"
                width="500"
                controls="controls"
                :state="viewVideo"
                ref="vueRef"
            ></video>
      </a-modal>
        </div>
      </div>


      


      <div class="writing_right_content" v-show="!showTable">
        <div class="right_content_lister">
          <div class="right_content_icon">
            <div class="content_icon_left"><img src="@a/img/bn1.png"/></div>
            <div class="content_icon_right"><img src="@a/img/sv47.svg"/>系统根据您输入的关键词来在线逐条生成标题，您可以选择需要的标题再创作文章，这种方法需要您在线手动操作，支持导入自己的标题，以及修改标题。如果您对生成的标题有严格要求可以按这种方式来操作。</div>
          </div>
          <div class="right_content_title">
            <div class="content_title_dd">
              <div class="title_dd_left">生成标题<span class="notBlue" @click="SeeVideo"><img src="@a/img2/sv66.svg"/>产品介绍</span></div>
              <span class="title_dd_btn" @click="importTitle=true">+
								直接导入标题</span>
            </div>
            <div class="content_title_dt">输入标题关键词，系统将根据您的标题关键词生成一系列标题。<br><span>为防止恶意刷标题生成，每生成一次标题扣除1个积分，您可以通过<a href="#/writing/titleGeneration/BackgroundHostingCreate">批量生成</a>来创建文章，这样就不会扣除标题1个积分</span></div>
          </div>
          <div class="right_content_form">
            <div class="content_form_top">
              <div class="form_top_left">
                <div class="top_left_icon"><i class="el-icon-search"></i></div>
                <div class="top_left_input"><input type="text" v-model="key_word"
                                                   placeholder="请输入要创建的标题关键词"/></div>
                <div class="top_left_num">
                  <el-select v-model="generated_quantity" placeholder="选择条数">
                    <el-option v-for="item in options" :key="item.value" :label="item.value + '条'"
                               :value="item.value" :disabled="item.disabled">
                      <template v-if="item.disabled">
												<span
                            style="color: #c2c2c2; margin-right: 15px;">{{ item.value }}条</span>
                        <el-tooltip class="item-tooltip" effect="dark" content="会员可用"
                                    placement="top-start">
                          <i class="el-icon-warning"></i>
                        </el-tooltip>
                      </template>
                    </el-option>
                  </el-select>
                </div>
                <div class="top_left_num">
                  <el-select v-model="generated_lang" placeholder="语言">
                    <el-option v-for="item in lang" :label="item" :value="item">
                    </el-option>
                  </el-select>
                </div>		
              </div>
              <div class="form_top_right" @click="doCreate">开始创建</div>
            </div>
            <div class="content_form_tag">
              <div class="form_tag_list" v-for="(v,index) in this.$store.getters.tags">
                <div class="tag_list_con" @click="key_word = v;">{{ v }}</div>
                <div class="tag_list_close" type="danger" @click="deleteItem(index)"><i
                    class="el-icon-close"></i></div>
              </div>
            </div>
            <div class="content_form_KeyWrds" :class="{ active: this.$store.getters.tags.length === 0}">
              <div class="form_KeyWrds_title">选择以下生成关键词，快速生成相关软文的标题：</div>
              <div class="form_KeyWrds_txt">
                <div class="KeyWrds_txt_list" v-for="(item, index) in items" :key="index"
                     @click="selectItem(item)">{{ item.name }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>


    </div>


    <!-- 充值弹窗 -->
    <rechargeWindow v-if="rechargeShow" @close="rechargeShow = false"></rechargeWindow>


  </div>


</template>

<script>
import {
  MessageBox,
  Message
} from 'element-ui';
import NProgress from 'nprogress';
import {
  Loading
} from 'element-ui';
import table from "@c/common/table/table";
import loginWindow from "@c/common/loginWindow/loginWindow";
import rechargeWindow from "@c/common/rechargeWindow/rechargeWindow";
import Nav from "@c/common/nav/nav";

export default {
  name: "titlegeneration",
  data() {
    return {
      viewVideo:false,
      // 视频链接   这个大家可以写上自己的视频地址
      videoUrl:'https://ai-dogimg.oss-cn-shanghai.aliyuncs.com/AIDOG.mp4',
      BHostingNav: 1,
      loadingInstance: null,
      rechargeShow: false,
      isPlaying: false,
      VideoShow: false,
      forbiddenwords_id: '',
      forbiddenwords_inc: [],
      items: [{
        name: '以“SCRM软件市场分析”为关键词生成相关标题',
        value: 'SCRM软件市场分析'
		}
      ],
      user_titles: '',
      importTitle: false,
      showTable: false,
      loading: false,
      lang: [],
      progress: 0,
      showLogin: false,
      colors: [{
        color: '#3662eb'
      },],
      key: '',
      timer: null,
      options: [],
      key_word: '',
      generated_quantity: 10,
	  img_inc:[],//图片分类
      generated_lang: '中文',
	  img_class_id: "",//图片分类id
	  gpt_id:"" ,//提示词id
      received_quantity: 0,
	  length_inc: [2500,2000,1500,1000,600],//文章字数选项
	  length: 2000,//默认文章字数
      showUpload: false,

      // table 列表用
      tableList: [],

      check_types: [{
        value: 0,
        label: '自动审核'
      }, {
        value: 1,
        label: '人工审核'
      }],
      check_type: 0,
      class_types: [],
      class_type: '',
      nextId: 6,
      show: false,
	  site_num:0,

    };
  },
  created() {
    this.getPageConfig()
    if (this.$store.getters.isLogin) {
      this.getArticleClass()
    }else{
		//未登录需要会员强制登录
		this.showLogin=true;
	}
    //语言
    this.axios.get('/api/ArticleTitle/getLanguage').then(res => {
      this.lang = res.result;
    })
	//伪禁词
    this.axios.get('/api/ArticleForbiddenwords/getForbiddenName').then(res => {
      this.forbiddenwords_inc = res.result;
    })
	//图片分类
	this.axios.get('/api/imgClass/list').then(res => {
		res.result.forEach(item => {
			item.isActive = false
		})
		this.img_inc = res.result
	})	
	//提示词
	this.axios.get('/api/ArticleTitle/get_gpt_strategy').then(res => {
		res.result.forEach(item => {
			item.isActive = false
		})
		this.gpt_inc = res.result
	})		
  },
  components: {
    table,
    loginWindow,
    Nav,
    rechargeWindow
  },
  computed: {
    selectAll: {
      get() {
        return this.tableList.every(info => info.checked)
      },
      set(value) {
        this.tableList.forEach(info => {
          info.checked = value
        })
      },
    },
    selectedCount() {
      return this.tableList.filter(info => info.checked).length
    },
    allCount() {
      return this.tableList.filter(info => info).length
    }
  },
  methods: {
    SeeVideo(){
     this.viewVideo = true
     this.$refs.vueRef.play();//播放  
     this.VideoShow = !this.VideoShow;
    },
 
    // 取消预览
    handleCancel(e) {
      this.viewVideo = false;
      this.$refs.vueRef.pause();//暂停
      this.VideoShow = !this.VideoShow;
    },
    changeBHostingNav(index) {
      this.BHostingNav = index;
    },
    //软文关键词
    selectItem(item) {
      this.key_word = item.value
    },
    addUserTitles() {
      let that = this;
      if (that.user_titles) {
        let arr = that.user_titles.split("\n");
        for (let i in arr) {
          if (arr[i]) {
            that.tableList.push({
              title: arr[i],
              checked: true,
              isActive: false,
              is_used: 0
            })
          }
        }
        that.user_titles = ''
        that.importTitle = false
        that.showTable = true;
      }


    },
    showClass() {
      this.getArticleClass();
      this.show = !this.show
    },
    getArticleClass() {
      let that = this;
      this.axios.get('/api/articleClass/list').then(res => {
        res.result.forEach(item => {
          item.isActive = false
        })
        that.class_types = res.result
      })
    },

    doCreate() {
      let that = this;
      if (this.key_word.length < 4) {
        Message.error('标题关键词不能少于4个字符');
        return false;
      }

      let url = '/api/ArticleTitle/getAccess';
      if (this.$store.getters.isLogin) {
        url = '/api/ArticleTitleMember/getAccess';
      }
      this.axios.post(url, {
        "key_word": that.key_word,
        "generated_quantity": that.generated_quantity,
        "generated_lang": that.generated_lang
      }).then(res => {
        if (res.code === 1) {
          this.$store.commit('pushTags', that.key_word)
          if (that.$store.getters.isLogin) {
            that.axios.get('/api/member/getInfo').then(res => {
              localStorage.setItem('memberInfo', JSON.stringify(res.result))
              that.$store.commit('setMemberInfo', res.result)
            })
			//获取这个用户下的站点数量,便于根据站点在右侧输入直接发布到站点，还是批量创作
			this.getSiteNum()
          }


          that.key = res.result.key
          that.tableList = []
          that.showTable = true;
          let source = new EventSource(that.baseURL +
              `/api/ArticleTitle/getTitle?key_word=${that.key_word}&generated_quantity=${that.generated_quantity}&generated_lang=${that.generated_lang}&event_name=chatgpt&key=${that.key}`
          );
          that.loading = true;
          that.received_quantity = 0;
          NProgress.start();
          //监听test事件
          source.addEventListener('chatgpt', function (event) {
            // console.log(event)
            // console.log(event.data)
            if (event.data) {
              if (event.data === 'end') {
                that.loading = false;
                NProgress.done();
                source.close()
              } else {
                that.received_quantity++;
                that.progress = Math.round((that.received_quantity / that
                    .generated_quantity) * 100);
                let res = JSON.parse(event.data)
                that.tableList.push({
                  title: res.title.replace(/^[\d、，,。\.][^\S\n]*/gm, ''),
                  is_used: res.is_used,
                  checked: true,
                  isActive: false,

                })
              }
            }

          });
        } else {
          if (res.result && res.result.action) {
            let action = res.result.action;
            if (action === 'recharge') {
              that.rechargeShow = true;
            }
            if (action === 'login') {
              that.showLogin = true;
            }
          }
        }
      })
    },
    getPageConfig() {
      this.axios.post('/api/articleTitle/getTitlePages', {
        is_login: this.$store.getters.isLogin
      }).then(res => {
        this.options = res.result
        this.generated_quantity = this.options[0].value
      })
    },
    active(num) {
      this.ins = num
    },
    deleteItem(index) {
      this.$message({
        type: 'success',
        message: '删除成功!'
      });
      // 用户点击确定后执行删除操作
      this.$store.commit('deleteTags', index)
    },

    // table 列表组件原来方法
    doCreateArticle(gosite) {
      let that = this;
      if (!this.$store.getters.isLogin) {
        let that = this;
        that.showLogin = true;
        return false;
      }
      let titles = [];
      this.tableList.forEach(item => {
        if (item.checked) {
          titles.push(item.title)
        }
      })
      if (titles.length == 0) {
        Message.error('没有选中标题')
        return false;
      }
      this.loadingInstance = Loading.service({});

      that.axios.post('/api/article/addArticle', {
        articles: titles,
        type: that.check_type,
        forbiddenwords_id: that.forbiddenwords_id,
        lang: that.generated_lang,
        article_class_id: that.class_type,
		img_class_id: that.img_class_id,
		gpt_id: that.gpt_id,
		length: that.length
      }).then(res => {

        that.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
          that.loadingInstance.close();
        });

        if (res.code === 1) {
			//如果该用户下没有站点，则创建完成后跳转到站点对接
			if(gosite==1){
			  that.$router.push({
				path: '/writing/siteManagement/autoEprogram',
			  })
			}else{
			  that.$router.push({
				path: '/writing/myArticles?state=1',
			  })
			}

		  //如果有站点就直接跳转到创作中的页面
        } else {
          if (res.result && res.result.action) {
            let action = res.result.action;
            if (action === 'recharge') {
              that.rechargeShow = true;
            }
            if (action === 'login') {
              that.showLogin = true;
            }
          }
        }

      })
    },
    //点击增加信息
    addItem() {
      this.class_types.push({
        id: 0,
        ToSort: 0,
        name: '',
        isActive: true
      });

    },
    //标题列表编辑
    toggleActive(index) {
      this.tableList.forEach((info, i) => {
        if (i === index) {
          info.isActive = !info.isActive;
        }
      });
      this.$nextTick(() => {
        const inputField = this.$refs.inputField[index];
        inputField.focus();
      });
    },
    //标题列表保存
    handleItemClick() {
      this.$refs.inputField.blur();
      this.$message.success('标题保存成功！')
    },
    //标题列表点击标题事件
    titleActive(index) {
      this.tableList.forEach((info, i) => {
        if (i === index) {
          info.isActive = !info.isActive;
        }
      });
      this.$nextTick(() => {
        const inputField = this.$refs.inputField[index];
        inputField.focus();
      });
    },
    //标题列表失去焦点保存
    toggleClass(index) {
      this.tableList.forEach((info, i) => {
        if (i === index) {
          info.isActive = !info.isActive;
        }
      });
      this.$message.success('标题保存成功！')
    },
    //分类设置保存、编辑
    toggleActive2(index) {
      let that = this;
      let thisData = this.class_types[index];
      // 新增或修改
      if (thisData.isActive) {
        if (thisData.id == 0) {
          //新增
          that.axios.post('/api/articleClass/add', {
            name: thisData.name,
            sort: thisData.sort ? thisData.sort : 0
          }).then(res => {
            if (res.code == 1) {
              that.getArticleClass()
              that.class_type = ''
              Message.success('新增成功！')
            }
          })
        } else {
          //修改
          that.axios.post('/api/articleClass/update', {
            id: thisData.id,
            name: thisData.name,
            sort: thisData.sort
          }).then(res => {
            if (res.code == 1) {
              that.getArticleClass()
              Message.success('修改成功！')
            }
          })
        }
      }
      this.class_types[index].isActive = !thisData.isActive
    },
    //分类设置删除
    deleteInfo2(index) {
      let that = this;
      const item = this.class_types[index];
      MessageBox.confirm(`确定删除${item.name}吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        that.axios.post('/api/articleClass/delete', {
          id: item.id
        }).then(res => {
          if (res.code == 1) {
            that.class_type = '';
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            that.getArticleClass()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
        // 用户点击取消或者弹窗关闭时不做任何操作
      });
    },
    //标题列表删除
    deleteInfo(index) {
      const item = this.tableList[index];
      MessageBox.confirm(`确定删除${item.title}吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
        // 用户点击确定后执行删除操作
        this.tableList.splice(index, 1);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
        // 用户点击取消或者弹窗关闭时不做任何操作
      });
    },
	//获取用户站点数量
	getSiteNum(){
		this.axios.get('/api/site/list', {
			params: {
				page: 1,
				list_rows: 1,
			}
		}).then(res => {
			this.site_num=res.result.total;
		})
	}
  },
}
</script>

<style>
@import "titleGeneration.css";
</style>
